package main

import (
	"controller"
	"net/http"
	"strings"
	"test"
)

// Default Request Handler
func defaultHandler(w http.ResponseWriter, r *http.Request) {
	urlPath := r.URL.Path
	if strings.Contains(urlPath, ".html") {
		controller.Detail(w, r)
	} else if strings.Contains(urlPath, "/tag/") {
		controller.Tag(w, r)
	} else if strings.Contains(urlPath, "/auto-post") {
		controller.AutoPost(w, r)
	} else if strings.Contains(urlPath, "/test/") {
		test.Test(w, r)
	} else if strings.Contains(urlPath, "/category/") {
		controller.Category(w, r)
	} else if strings.Contains(urlPath, "/search/") {
		controller.Search(w, r)
	} else if strings.Contains(urlPath, "/time/") {
		controller.TimePage(w, r)
	} else {
		controller.Home(w, r)
	}
}

func init() {

	http.HandleFunc("/", defaultHandler)
	http.ListenAndServe(":80", nil)

}
